﻿
using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using DBUtility;

namespace XQ.SP.DalServices
{
    //测试部分控件
    public partial class TestControlsDal : BaseDal
    {

        public bool ExistsWhere(string whereSql)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from TestControls");
            if (whereSql != "")
            {
                strSql.Append(" where " + whereSql);
            }

            return DbHelperSQL.Exists(strSql.ToString());
        }
        public bool Exists(long id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from [TestControls]");
            strSql.Append(" where  [Id]=@Id ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
            parameters[0].Value = id;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }



        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(XQ.SP.Model.TestControlsItem model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [TestControls](");
            strSql.Append("[Name],[Description],[ImagePath],[ImagesPath],[FilePath],[FilesPath],[CheckState1],[CheckState2],[CheckState3],[FilesPath5],[FilesPath4],[FilesPath3],[FilesPath2],[Status],[Creator],[Created],[Modifier],[Modified],[TestTypeId],[TestTypeName],[FileType1Id],[FileType2Id],[SysRoleId]");
            strSql.Append(") values (");
                strSql.Append("@Name,@Description,@ImagePath,@ImagesPath,@FilePath,@FilesPath,@CheckState1,@CheckState2,@CheckState3,@FilesPath5,@FilesPath4,@FilesPath3,@FilesPath2,@Status,@Creator,@Created,@Modifier,@Modified,@TestTypeId,@TestTypeName,@FileType1Id,@FileType2Id,@SysRoleId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@Name", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@Description", SqlDbType.Text,16) ,            
			            new SqlParameter("@ImagePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@ImagesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState1", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath5", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath4", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@TestTypeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@TestTypeName", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@FileType1Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@FileType2Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysRoleId", SqlDbType.NVarChar,4000) ,            
            };
            
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Description;
            parameters[2].Value = model.ImagePath;
            parameters[3].Value = model.ImagesPath;
            parameters[4].Value = model.FilePath;
            parameters[5].Value = model.FilesPath;
            parameters[6].Value = model.CheckState1;
            parameters[7].Value = model.CheckState2;
            parameters[8].Value = model.CheckState3;
            parameters[9].Value = model.FilesPath5;
            parameters[10].Value = model.FilesPath4;
            parameters[11].Value = model.FilesPath3;
            parameters[12].Value = model.FilesPath2;
            parameters[13].Value = model.Status;
            parameters[14].Value = model.Creator;
            parameters[15].Value = model.Created;
            parameters[16].Value = model.Modifier;
            parameters[17].Value = model.Modified;
            parameters[18].Value = model.TestTypeId;
            parameters[19].Value = model.TestTypeName;
            parameters[20].Value = model.FileType1Id;
            parameters[21].Value = model.FileType2Id;
            parameters[22].Value = model.SysRoleId;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt64(obj);
            }

        }

        /// <summary>
        ///   批量添加数据
        /// </summary>
        public int AddList(List<XQ.SP.Model.TestControlsItem> models)
        {
            List<CommandInfo> commands = new List<CommandInfo>();
            foreach (XQ.SP.Model.TestControlsItem model in models)
            {
                CommandInfo command = new CommandInfo();
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into [TestControls](");
                strSql.Append("[Name],[Description],[ImagePath],[ImagesPath],[FilePath],[FilesPath],[CheckState1],[CheckState2],[CheckState3],[FilesPath5],[FilesPath4],[FilesPath3],[FilesPath2],[Status],[Creator],[Created],[Modifier],[Modified],[TestTypeId],[TestTypeName],[FileType1Id],[FileType2Id],[SysRoleId]");
                strSql.Append(") values (");
                strSql.Append("@Name,@Description,@ImagePath,@ImagesPath,@FilePath,@FilesPath,@CheckState1,@CheckState2,@CheckState3,@FilesPath5,@FilesPath4,@FilesPath3,@FilesPath2,@Status,@Creator,@Created,@Modifier,@Modified,@TestTypeId,@TestTypeName,@FileType1Id,@FileType2Id,@SysRoleId");
                strSql.Append(") ");
                strSql.Append(";select @@IDENTITY");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@Name", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@Description", SqlDbType.Text,16) ,            
			            new SqlParameter("@ImagePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@ImagesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState1", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath5", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath4", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@TestTypeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@TestTypeName", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@FileType1Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@FileType2Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysRoleId", SqlDbType.NVarChar,4000) ,            
            };
            
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Description;
            parameters[2].Value = model.ImagePath;
            parameters[3].Value = model.ImagesPath;
            parameters[4].Value = model.FilePath;
            parameters[5].Value = model.FilesPath;
            parameters[6].Value = model.CheckState1;
            parameters[7].Value = model.CheckState2;
            parameters[8].Value = model.CheckState3;
            parameters[9].Value = model.FilesPath5;
            parameters[10].Value = model.FilesPath4;
            parameters[11].Value = model.FilesPath3;
            parameters[12].Value = model.FilesPath2;
            parameters[13].Value = model.Status;
            parameters[14].Value = model.Creator;
            parameters[15].Value = model.Created;
            parameters[16].Value = model.Modifier;
            parameters[17].Value = model.Modified;
            parameters[18].Value = model.TestTypeId;
            parameters[19].Value = model.TestTypeName;
            parameters[20].Value = model.FileType1Id;
            parameters[21].Value = model.FileType2Id;
            parameters[22].Value = model.SysRoleId;
                command.CommandText = strSql.ToString();
                command.Parameters = parameters;
                commands.Add(command);
            }
            object obj = DbHelperSQL.ExecuteSqlTran(commands);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }


        /// <summary>
        /// 批量更新数据
        /// </summary>
        public int UpdateList(List<XQ.SP.Model.TestControlsItem> models)
        {
            List<CommandInfo> commands = new List<CommandInfo>();
            CommandInfo command = new CommandInfo();

            foreach (XQ.SP.Model.TestControlsItem model in models)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update [TestControls] set ");
            
                strSql.Append(" [Name] = @Name,");
                strSql.Append(" [Description] = @Description,");
                strSql.Append(" [ImagePath] = @ImagePath,");
                strSql.Append(" [ImagesPath] = @ImagesPath,");
                strSql.Append(" [FilePath] = @FilePath,");
                strSql.Append(" [FilesPath] = @FilesPath,");
                strSql.Append(" [CheckState1] = @CheckState1,");
                strSql.Append(" [CheckState2] = @CheckState2,");
                strSql.Append(" [CheckState3] = @CheckState3,");
                strSql.Append(" [FilesPath5] = @FilesPath5,");
                strSql.Append(" [FilesPath4] = @FilesPath4,");
                strSql.Append(" [FilesPath3] = @FilesPath3,");
                strSql.Append(" [FilesPath2] = @FilesPath2,");
                strSql.Append(" [Status] = @Status,");
                strSql.Append(" [Creator] = @Creator,");
                strSql.Append(" [Created] = @Created,");
                strSql.Append(" [Modifier] = @Modifier,");
                strSql.Append(" [Modified] = @Modified,");
                strSql.Append(" [TestTypeId] = @TestTypeId,");
                strSql.Append(" [TestTypeName] = @TestTypeName,");
                strSql.Append(" [FileType1Id] = @FileType1Id,");
                strSql.Append(" [FileType2Id] = @FileType2Id,");
                strSql.Append(" [SysRoleId] = @SysRoleId");
                strSql.Append(" where [Id]=@Id ");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Name", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@Description", SqlDbType.Text,16) ,            
			            new SqlParameter("@ImagePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@ImagesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState1", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath5", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath4", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@TestTypeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@TestTypeName", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@FileType1Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@FileType2Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysRoleId", SqlDbType.NVarChar,4000) ,            
            };
            
            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Description;
            parameters[3].Value = model.ImagePath;
            parameters[4].Value = model.ImagesPath;
            parameters[5].Value = model.FilePath;
            parameters[6].Value = model.FilesPath;
            parameters[7].Value = model.CheckState1;
            parameters[8].Value = model.CheckState2;
            parameters[9].Value = model.CheckState3;
            parameters[10].Value = model.FilesPath5;
            parameters[11].Value = model.FilesPath4;
            parameters[12].Value = model.FilesPath3;
            parameters[13].Value = model.FilesPath2;
            parameters[14].Value = model.Status;
            parameters[15].Value = model.Creator;
            parameters[16].Value = model.Created;
            parameters[17].Value = model.Modifier;
            parameters[18].Value = model.Modified;
            parameters[19].Value = model.TestTypeId;
            parameters[20].Value = model.TestTypeName;
            parameters[21].Value = model.FileType1Id;
            parameters[22].Value = model.FileType2Id;
            parameters[23].Value = model.SysRoleId;
                command.CommandText = strSql.ToString();
                command.Parameters = parameters;
                commands.Add(command);
            }

            int rows = DbHelperSQL.ExecuteSqlTran(commands);
            return rows;

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XQ.SP.Model.TestControlsItem model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update [TestControls] set ");
            
                strSql.Append(" [Name] = @Name,");
                strSql.Append(" [Description] = @Description,");
                strSql.Append(" [ImagePath] = @ImagePath,");
                strSql.Append(" [ImagesPath] = @ImagesPath,");
                strSql.Append(" [FilePath] = @FilePath,");
                strSql.Append(" [FilesPath] = @FilesPath,");
                strSql.Append(" [CheckState1] = @CheckState1,");
                strSql.Append(" [CheckState2] = @CheckState2,");
                strSql.Append(" [CheckState3] = @CheckState3,");
                strSql.Append(" [FilesPath5] = @FilesPath5,");
                strSql.Append(" [FilesPath4] = @FilesPath4,");
                strSql.Append(" [FilesPath3] = @FilesPath3,");
                strSql.Append(" [FilesPath2] = @FilesPath2,");
                strSql.Append(" [Status] = @Status,");
                strSql.Append(" [Creator] = @Creator,");
                strSql.Append(" [Created] = @Created,");
                strSql.Append(" [Modifier] = @Modifier,");
                strSql.Append(" [Modified] = @Modified,");
                strSql.Append(" [TestTypeId] = @TestTypeId,");
                strSql.Append(" [TestTypeName] = @TestTypeName,");
                strSql.Append(" [FileType1Id] = @FileType1Id,");
                strSql.Append(" [FileType2Id] = @FileType2Id,");
                strSql.Append(" [SysRoleId] = @SysRoleId");
                strSql.Append(" where [Id]=@Id ");
            
                        SqlParameter[] parameters = {
			            new SqlParameter("@Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Name", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@Description", SqlDbType.Text,16) ,            
			            new SqlParameter("@ImagePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@ImagesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilePath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState1", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@CheckState3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath5", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath4", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath3", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@FilesPath2", SqlDbType.NVarChar,4000) ,            
			            new SqlParameter("@Status", SqlDbType.Int,4) ,            
			            new SqlParameter("@Creator", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Created", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@Modifier", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@Modified", SqlDbType.DateTime,8) ,            
			            new SqlParameter("@TestTypeId", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@TestTypeName", SqlDbType.NVarChar,400) ,            
			            new SqlParameter("@FileType1Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@FileType2Id", SqlDbType.BigInt,8) ,            
			            new SqlParameter("@SysRoleId", SqlDbType.NVarChar,4000) ,            
            };
            
            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Description;
            parameters[3].Value = model.ImagePath;
            parameters[4].Value = model.ImagesPath;
            parameters[5].Value = model.FilePath;
            parameters[6].Value = model.FilesPath;
            parameters[7].Value = model.CheckState1;
            parameters[8].Value = model.CheckState2;
            parameters[9].Value = model.CheckState3;
            parameters[10].Value = model.FilesPath5;
            parameters[11].Value = model.FilesPath4;
            parameters[12].Value = model.FilesPath3;
            parameters[13].Value = model.FilesPath2;
            parameters[14].Value = model.Status;
            parameters[15].Value = model.Creator;
            parameters[16].Value = model.Created;
            parameters[17].Value = model.Modifier;
            parameters[18].Value = model.Modified;
            parameters[19].Value = model.TestTypeId;
            parameters[20].Value = model.TestTypeName;
            parameters[21].Value = model.FileType1Id;
            parameters[22].Value = model.FileType2Id;
            parameters[23].Value = model.SysRoleId;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }



        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(long Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from TestControls ");
            strSql.Append(" where Id=@Id  ");
            SqlParameter[] parameters = {new SqlParameter("@Id", SqlDbType.BigInt)};
            parameters[0].Value = Id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string Idlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from TestControls ");
            strSql.Append(" where Id in (" + Idlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XQ.SP.Model.TestControlsItem GetModel(long Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *  ");
            strSql.Append("  from TestControls ");
            strSql.Append(" where Id=@Id  ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.BigInt)
			};
            parameters[0].Value = Id;


            XQ.SP.Model.TestControlsItem model = new XQ.SP.Model.TestControlsItem();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = Int64.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Description"].ToString() != "")
                {
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ImagePath"].ToString() != "")
                {
                    model.ImagePath = ds.Tables[0].Rows[0]["ImagePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ImagesPath"].ToString() != "")
                {
                    model.ImagesPath = ds.Tables[0].Rows[0]["ImagesPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilePath"].ToString() != "")
                {
                    model.FilePath = ds.Tables[0].Rows[0]["FilePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath"].ToString() != "")
                {
                    model.FilesPath = ds.Tables[0].Rows[0]["FilesPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CheckState1"].ToString() != "")
                {
                    model.CheckState1 = ds.Tables[0].Rows[0]["CheckState1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CheckState2"].ToString() != "")
                {
                    model.CheckState2 = ds.Tables[0].Rows[0]["CheckState2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CheckState3"].ToString() != "")
                {
                    model.CheckState3 = ds.Tables[0].Rows[0]["CheckState3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath5"].ToString() != "")
                {
                    model.FilesPath5 = ds.Tables[0].Rows[0]["FilesPath5"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath4"].ToString() != "")
                {
                    model.FilesPath4 = ds.Tables[0].Rows[0]["FilesPath4"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath3"].ToString() != "")
                {
                    model.FilesPath3 = ds.Tables[0].Rows[0]["FilesPath3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath2"].ToString() != "")
                {
                    model.FilesPath2 = ds.Tables[0].Rows[0]["FilesPath2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = Int32.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Creator"].ToString() != "")
                {
                    model.Creator = Int64.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Created"].ToString() != "")
                {
                    model.Created = System.DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modifier"].ToString() != "")
                {
                    model.Modifier = Int64.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modified"].ToString() != "")
                {
                    model.Modified = System.DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TestTypeId"].ToString() != "")
                {
                    model.TestTypeId = Int64.Parse(ds.Tables[0].Rows[0]["TestTypeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TestTypeName"].ToString() != "")
                {
                    model.TestTypeName = ds.Tables[0].Rows[0]["TestTypeName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FileType1Id"].ToString() != "")
                {
                    model.FileType1Id = Int64.Parse(ds.Tables[0].Rows[0]["FileType1Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FileType2Id"].ToString() != "")
                {
                    model.FileType2Id = Int64.Parse(ds.Tables[0].Rows[0]["FileType2Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SysRoleId"].ToString() != "")
                {
                    model.SysRoleId = ds.Tables[0].Rows[0]["SysRoleId"].ToString();
                }

                return model;
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XQ.SP.Model.TestControlsItem GetModelWhereStr(string whereStr)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *  ");
            strSql.Append("  from TestControls ");
            if (whereStr != "")
            {
                strSql.Append(" where " + whereStr);
            }

            XQ.SP.Model.TestControlsItem model = new XQ.SP.Model.TestControlsItem();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = Int64.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Description"].ToString() != "")
                {
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ImagePath"].ToString() != "")
                {
                    model.ImagePath = ds.Tables[0].Rows[0]["ImagePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ImagesPath"].ToString() != "")
                {
                    model.ImagesPath = ds.Tables[0].Rows[0]["ImagesPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilePath"].ToString() != "")
                {
                    model.FilePath = ds.Tables[0].Rows[0]["FilePath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath"].ToString() != "")
                {
                    model.FilesPath = ds.Tables[0].Rows[0]["FilesPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CheckState1"].ToString() != "")
                {
                    model.CheckState1 = ds.Tables[0].Rows[0]["CheckState1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CheckState2"].ToString() != "")
                {
                    model.CheckState2 = ds.Tables[0].Rows[0]["CheckState2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CheckState3"].ToString() != "")
                {
                    model.CheckState3 = ds.Tables[0].Rows[0]["CheckState3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath5"].ToString() != "")
                {
                    model.FilesPath5 = ds.Tables[0].Rows[0]["FilesPath5"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath4"].ToString() != "")
                {
                    model.FilesPath4 = ds.Tables[0].Rows[0]["FilesPath4"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath3"].ToString() != "")
                {
                    model.FilesPath3 = ds.Tables[0].Rows[0]["FilesPath3"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FilesPath2"].ToString() != "")
                {
                    model.FilesPath2 = ds.Tables[0].Rows[0]["FilesPath2"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = Int32.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Creator"].ToString() != "")
                {
                    model.Creator = Int64.Parse(ds.Tables[0].Rows[0]["Creator"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Created"].ToString() != "")
                {
                    model.Created = System.DateTime.Parse(ds.Tables[0].Rows[0]["Created"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modifier"].ToString() != "")
                {
                    model.Modifier = Int64.Parse(ds.Tables[0].Rows[0]["Modifier"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Modified"].ToString() != "")
                {
                    model.Modified = System.DateTime.Parse(ds.Tables[0].Rows[0]["Modified"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TestTypeId"].ToString() != "")
                {
                    model.TestTypeId = Int64.Parse(ds.Tables[0].Rows[0]["TestTypeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TestTypeName"].ToString() != "")
                {
                    model.TestTypeName = ds.Tables[0].Rows[0]["TestTypeName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FileType1Id"].ToString() != "")
                {
                    model.FileType1Id = Int64.Parse(ds.Tables[0].Rows[0]["FileType1Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FileType2Id"].ToString() != "")
                {
                    model.FileType2Id = Int64.Parse(ds.Tables[0].Rows[0]["FileType2Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SysRoleId"].ToString() != "")
                {
                    model.SysRoleId = ds.Tables[0].Rows[0]["SysRoleId"].ToString();
                }

                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM TestControls ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" * ");
            strSql.Append(" FROM TestControls ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

    }
}

